﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace zielonka.co.uk.extensions.system
{
    //Description : Returns a formatted string on a nullable double
    /*
        double? pi = null;

        string s = pi.ToString("0.00"); //s = ""
        pi = Math.Pi;

        s = pi.ToString("0.00");  //s = 3.14

     */

    public static partial class DoubleExtensions
    {
        /// <summary>
        /// Returns a formatted double or emtpy string
        /// </summary>
        /// <param name="t">double or null</param>
        /// <param name="format">double formatstring </param>
        /// <returns></returns>
        public static string ToString(this double? t, string format)
        {
            if (t != null)
            {
                return t.Value.ToString(format);
            }

            return "";
        }
    }
}
